﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Rendering.RenderTargetIdentifier
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;

#nullable disable
namespace UnityEngine.Rendering
{
  /// <summary>
  ///   <para>Identifies a RenderTexture for a Rendering.CommandBuffer.</para>
  /// </summary>
  public struct RenderTargetIdentifier : IEquatable<RenderTargetIdentifier>
  {
    /// <summary>
    ///   <para>All depth-slices of the render resource are bound for rendering. For textures which are neither array nor 3D, the default slice is bound.</para>
    /// </summary>
    public const int AllDepthSlices = -1;
    private BuiltinRenderTextureType m_Type;
    private int m_NameID;
    private int m_InstanceID;
    private IntPtr m_BufferPointer;
    private int m_MipLevel;
    private CubemapFace m_CubeFace;
    private int m_DepthSlice;

    /// <summary>
    ///   <para>Creates a render target identifier.</para>
    /// </summary>
    /// <param name="type">Built-in temporary render texture type.</param>
    /// <param name="name">Temporary render texture name.</param>
    /// <param name="nameID">Temporary render texture name (as integer, see Shader.PropertyToID).</param>
    /// <param name="tex">RenderTexture or Texture object to use.</param>
    /// <param name="mipLevel">MipLevel of the RenderTexture to use.</param>
    /// <param name="cubemapFace">Cubemap face of the Cubemap RenderTexture to use.</param>
    /// <param name="depthSlice">Depth slice of the Array RenderTexture to use. The symbolic constant RenderTargetIdentifier.AllDepthSlices indicates that all slices should be bound for rendering. The default value is 0.</param>
    /// <param name="renderTargetIdentifier">An existing render target identifier.</param>
    /// <param name="cubeFace"></param>
    public RenderTargetIdentifier(BuiltinRenderTextureType type)
    {
      this.m_Type = type;
      this.m_NameID = -1;
      this.m_InstanceID = 0;
      this.m_BufferPointer = IntPtr.Zero;
      this.m_MipLevel = 0;
      this.m_CubeFace = CubemapFace.Unknown;
      this.m_DepthSlice = 0;
    }

    public RenderTargetIdentifier(
      BuiltinRenderTextureType type,
      int mipLevel = 0,
      CubemapFace cubeFace = CubemapFace.Unknown,
      int depthSlice = 0)
    {
      this.m_Type = type;
      this.m_NameID = -1;
      this.m_InstanceID = 0;
      this.m_BufferPointer = IntPtr.Zero;
      this.m_MipLevel = mipLevel;
      this.m_CubeFace = cubeFace;
      this.m_DepthSlice = depthSlice;
    }

    /// <summary>
    ///   <para>Creates a render target identifier.</para>
    /// </summary>
    /// <param name="type">Built-in temporary render texture type.</param>
    /// <param name="name">Temporary render texture name.</param>
    /// <param name="nameID">Temporary render texture name (as integer, see Shader.PropertyToID).</param>
    /// <param name="tex">RenderTexture or Texture object to use.</param>
    /// <param name="mipLevel">MipLevel of the RenderTexture to use.</param>
    /// <param name="cubemapFace">Cubemap face of the Cubemap RenderTexture to use.</param>
    /// <param name="depthSlice">Depth slice of the Array RenderTexture to use. The symbolic constant RenderTargetIdentifier.AllDepthSlices indicates that all slices should be bound for rendering. The default value is 0.</param>
    /// <param name="renderTargetIdentifier">An existing render target identifier.</param>
    /// <param name="cubeFace"></param>
    public RenderTargetIdentifier(string name)
    {
      this.m_Type = BuiltinRenderTextureType.PropertyName;
      this.m_NameID = Shader.PropertyToID(name);
      this.m_InstanceID = 0;
      this.m_BufferPointer = IntPtr.Zero;
      this.m_MipLevel = 0;
      this.m_CubeFace = CubemapFace.Unknown;
      this.m_DepthSlice = 0;
    }

    public RenderTargetIdentifier(string name, int mipLevel = 0, CubemapFace cubeFace = CubemapFace.Unknown, int depthSlice = 0)
    {
      this.m_Type = BuiltinRenderTextureType.PropertyName;
      this.m_NameID = Shader.PropertyToID(name);
      this.m_InstanceID = 0;
      this.m_BufferPointer = IntPtr.Zero;
      this.m_MipLevel = mipLevel;
      this.m_CubeFace = cubeFace;
      this.m_DepthSlice = depthSlice;
    }

    /// <summary>
    ///   <para>Creates a render target identifier.</para>
    /// </summary>
    /// <param name="type">Built-in temporary render texture type.</param>
    /// <param name="name">Temporary render texture name.</param>
    /// <param name="nameID">Temporary render texture name (as integer, see Shader.PropertyToID).</param>
    /// <param name="tex">RenderTexture or Texture object to use.</param>
    /// <param name="mipLevel">MipLevel of the RenderTexture to use.</param>
    /// <param name="cubemapFace">Cubemap face of the Cubemap RenderTexture to use.</param>
    /// <param name="depthSlice">Depth slice of the Array RenderTexture to use. The symbolic constant RenderTargetIdentifier.AllDepthSlices indicates that all slices should be bound for rendering. The default value is 0.</param>
    /// <param name="renderTargetIdentifier">An existing render target identifier.</param>
    /// <param name="cubeFace"></param>
    public RenderTargetIdentifier(int nameID)
    {
      this.m_Type = BuiltinRenderTextureType.PropertyName;
      this.m_NameID = nameID;
      this.m_InstanceID = 0;
      this.m_BufferPointer = IntPtr.Zero;
      this.m_MipLevel = 0;
      this.m_CubeFace = CubemapFace.Unknown;
      this.m_DepthSlice = 0;
    }

    public RenderTargetIdentifier(int nameID, int mipLevel = 0, CubemapFace cubeFace = CubemapFace.Unknown, int depthSlice = 0)
    {
      this.m_Type = BuiltinRenderTextureType.PropertyName;
      this.m_NameID = nameID;
      this.m_InstanceID = 0;
      this.m_BufferPointer = IntPtr.Zero;
      this.m_MipLevel = mipLevel;
      this.m_CubeFace = cubeFace;
      this.m_DepthSlice = depthSlice;
    }

    /// <summary>
    ///   <para>Creates a render target identifier.</para>
    /// </summary>
    /// <param name="type">Built-in temporary render texture type.</param>
    /// <param name="name">Temporary render texture name.</param>
    /// <param name="nameID">Temporary render texture name (as integer, see Shader.PropertyToID).</param>
    /// <param name="tex">RenderTexture or Texture object to use.</param>
    /// <param name="mipLevel">MipLevel of the RenderTexture to use.</param>
    /// <param name="cubemapFace">Cubemap face of the Cubemap RenderTexture to use.</param>
    /// <param name="depthSlice">Depth slice of the Array RenderTexture to use. The symbolic constant RenderTargetIdentifier.AllDepthSlices indicates that all slices should be bound for rendering. The default value is 0.</param>
    /// <param name="renderTargetIdentifier">An existing render target identifier.</param>
    /// <param name="cubeFace"></param>
    public RenderTargetIdentifier(
      RenderTargetIdentifier renderTargetIdentifier,
      int mipLevel,
      CubemapFace cubeFace = CubemapFace.Unknown,
      int depthSlice = 0)
    {
      this.m_Type = renderTargetIdentifier.m_Type;
      this.m_NameID = renderTargetIdentifier.m_NameID;
      this.m_InstanceID = renderTargetIdentifier.m_InstanceID;
      this.m_BufferPointer = renderTargetIdentifier.m_BufferPointer;
      this.m_MipLevel = mipLevel;
      this.m_CubeFace = cubeFace;
      this.m_DepthSlice = depthSlice;
    }

    /// <summary>
    ///   <para>Creates a render target identifier.</para>
    /// </summary>
    /// <param name="type">Built-in temporary render texture type.</param>
    /// <param name="name">Temporary render texture name.</param>
    /// <param name="nameID">Temporary render texture name (as integer, see Shader.PropertyToID).</param>
    /// <param name="tex">RenderTexture or Texture object to use.</param>
    /// <param name="mipLevel">MipLevel of the RenderTexture to use.</param>
    /// <param name="cubemapFace">Cubemap face of the Cubemap RenderTexture to use.</param>
    /// <param name="depthSlice">Depth slice of the Array RenderTexture to use. The symbolic constant RenderTargetIdentifier.AllDepthSlices indicates that all slices should be bound for rendering. The default value is 0.</param>
    /// <param name="renderTargetIdentifier">An existing render target identifier.</param>
    /// <param name="cubeFace"></param>
    public RenderTargetIdentifier(Texture tex)
    {
      this.m_Type = !((UnityEngine.Object) tex == (UnityEngine.Object) null) ? (!(tex is RenderTexture) ? BuiltinRenderTextureType.BindableTexture : BuiltinRenderTextureType.RenderTexture) : BuiltinRenderTextureType.None;
      this.m_BufferPointer = IntPtr.Zero;
      this.m_NameID = -1;
      this.m_InstanceID = (bool) (UnityEngine.Object) tex ? tex.GetInstanceID() : 0;
      this.m_MipLevel = 0;
      this.m_CubeFace = CubemapFace.Unknown;
      this.m_DepthSlice = 0;
    }

    public RenderTargetIdentifier(Texture tex, int mipLevel = 0, CubemapFace cubeFace = CubemapFace.Unknown, int depthSlice = 0)
    {
      this.m_Type = !((UnityEngine.Object) tex == (UnityEngine.Object) null) ? (!(tex is RenderTexture) ? BuiltinRenderTextureType.BindableTexture : BuiltinRenderTextureType.RenderTexture) : BuiltinRenderTextureType.None;
      this.m_BufferPointer = IntPtr.Zero;
      this.m_NameID = -1;
      this.m_InstanceID = (bool) (UnityEngine.Object) tex ? tex.GetInstanceID() : 0;
      this.m_MipLevel = mipLevel;
      this.m_CubeFace = cubeFace;
      this.m_DepthSlice = depthSlice;
    }

    public RenderTargetIdentifier(
      RenderBuffer buf,
      int mipLevel = 0,
      CubemapFace cubeFace = CubemapFace.Unknown,
      int depthSlice = 0)
    {
      this.m_Type = BuiltinRenderTextureType.BufferPtr;
      this.m_NameID = -1;
      this.m_InstanceID = buf.m_RenderTextureInstanceID;
      this.m_BufferPointer = buf.m_BufferPtr;
      this.m_MipLevel = mipLevel;
      this.m_CubeFace = cubeFace;
      this.m_DepthSlice = depthSlice;
    }

    public static implicit operator RenderTargetIdentifier(BuiltinRenderTextureType type)
    {
      return new RenderTargetIdentifier(type);
    }

    public static implicit operator RenderTargetIdentifier(string name)
    {
      return new RenderTargetIdentifier(name);
    }

    public static implicit operator RenderTargetIdentifier(int nameID)
    {
      return new RenderTargetIdentifier(nameID);
    }

    public static implicit operator RenderTargetIdentifier(Texture tex)
    {
      return new RenderTargetIdentifier(tex);
    }

    public static implicit operator RenderTargetIdentifier(RenderBuffer buf)
    {
      return new RenderTargetIdentifier(buf);
    }

    public override string ToString()
    {
      return UnityString.Format("Type {0} NameID {1} InstanceID {2} BufferPointer {3} MipLevel {4} CubeFace {5} DepthSlice {6}", (object) this.m_Type, (object) this.m_NameID, (object) this.m_InstanceID, (object) this.m_BufferPointer, (object) this.m_MipLevel, (object) this.m_CubeFace, (object) this.m_DepthSlice);
    }

    public override int GetHashCode()
    {
      return (this.m_Type.GetHashCode() * 23 + this.m_NameID.GetHashCode()) * 23 + this.m_InstanceID.GetHashCode();
    }

    public bool Equals(RenderTargetIdentifier rhs)
    {
      return this.m_Type == rhs.m_Type && this.m_NameID == rhs.m_NameID && this.m_InstanceID == rhs.m_InstanceID && this.m_BufferPointer == rhs.m_BufferPointer && this.m_MipLevel == rhs.m_MipLevel && this.m_CubeFace == rhs.m_CubeFace && this.m_DepthSlice == rhs.m_DepthSlice;
    }

    public override bool Equals(object obj)
    {
      return obj is RenderTargetIdentifier rhs && this.Equals(rhs);
    }

    public static bool operator ==(RenderTargetIdentifier lhs, RenderTargetIdentifier rhs)
    {
      return lhs.Equals(rhs);
    }

    public static bool operator !=(RenderTargetIdentifier lhs, RenderTargetIdentifier rhs)
    {
      return !lhs.Equals(rhs);
    }
  }
}
